//Usage:   replace.js filename old new
var filename = WScript.Arguments(0);
var old = WScript.Arguments(1);
var sub = WScript.Arguments(2);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile(filename);
var content = file.ReadAll();
content = content.replace(new RegExp(old, "gm"), sub);
file.Close();
var file = fso.CreateTextFile(filename + ".txt");
file.Write(content);
file.Close();